package com.dlg.user.filter;

import org.springframework.core.annotation.Order;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * Xss/sql 过滤 
 * @author mwz
 * @since  2017年6月12日 下午6:58:42
 */
/*@Order(1)
@WebFilter(urlPatterns = "/*", filterName = "xssAndSqlFilter")*/
public class XssAndSqlFilter implements Filter {

	@Override
	public void init(FilterConfig filterConfig) throws ServletException {
		// TODO Auto-generated method stub
	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
                         FilterChain chain) throws IOException, ServletException {
		try {
			 chain.doFilter(new XssAndSqlHttpServletRequestWrapper((HttpServletRequest) request), response);
		} catch (Exception e) {
			response.getWriter().print(e.getMessage());
			response.getWriter().flush();
			response.getWriter().close();
		}
	}

	@Override
	public void destroy() {
		// TODO Auto-generated method stub
	}

}
